package com.hrzyit.whistle.comm.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.comm.data.bean.ContactEntity
import com.hrzyit.whistle.comm.presenter.view.ContactsView
import com.hrzyit.whistle.comm.service.IContactsService
import javax.inject.Inject

/**
 * 通讯录：人员相关 Presenter 逻辑
 * @author YangWei
 * @date 2019/3/24
 */
class ContactsPresenter @Inject constructor() : BasePresenter<ContactsView>() {
    @Inject
    lateinit var contactsService: IContactsService

    /**
     * 获取单位人员列表信息列表
     * @author YangWei
     * @date 2019/5/6
     * @param deptId    单位id
     * @return 单位人员列表信息列表 {@link ContactEntity}
     */
    fun selectContactsList(deptId: Long) {

        if (!checkNetWork()) {
            return
        }

        // 显示进度框
        mView.showLoading()

        contactsService.selectContactsList(deptId)
            .execute(object : BaseObserver<MutableList<ContactEntity>>(mView) {
                override fun onNext(t: MutableList<ContactEntity>) {
                    mView.onGetSelectContactsListSuccess(t)
                }
            }, lifecycleProvider)
    }
}